package com.ebc.eservice.controller.pc;

import com.ebc.eservice.service.EbcRoleService;
import com.ebc.eservice.util.JsonResult;
import com.ebc.eservice.util.common.constant.ApiTextHelperConstant;
import com.ebc.eservice.util.common.constant.DeveloperConstant;
import com.ebc.eservice.vo.Role.ModifyRoleRespVo;
import com.ebc.eservice.vo.Role.addRoleReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: Joey
 * @Description:权限管理
 * @date:2022/9/18 0:26
 */
@Api(tags = "后台管理系统-设置-角色管理")
@RestController
@RequestMapping("/system/roleMange")
public class RoleController {

    @Autowired
    private EbcRoleService ebcRoleService;

    //获取角色
    @ApiOperation(value = "获取全部角色信息", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @GetMapping("/getRoleList")
    public JsonResult getRoleList(){
        return ebcRoleService.getRoleList();
    }

    //获取菜单列表
    @ApiOperation(value = "获取菜单权限列表", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @GetMapping("/getMenuList")
    public JsonResult getMenuList(){
        return ebcRoleService.getMenuList();
    }
    //添加
    @ApiOperation(value = "添加角色", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH
            +"树状图参数传入-整型列表,列表长度必须是19位")
    @PostMapping("/addNewRoleMenu")
    public JsonResult addNewRoleMenu(@RequestBody addRoleReqVo RoleReqVo){
        System.out.println("添加角色:"+RoleReqVo);
        return ebcRoleService.addNewRole(RoleReqVo);
    }

    //更新
    @ApiOperation(value = "更新角色信息", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH
            +"树状图参数传入-整型[数据只能包含0或1]列表 ")
    @PostMapping("/modifyRoleMenu")
    public JsonResult modifyRoleMenu(@RequestBody ModifyRoleRespVo modifyRoleRespVo){
        return ebcRoleService.ModifyMenuRole(modifyRoleRespVo);
    }
    //更新
    @ApiOperation(value = "删除[停用]角色", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH
            +"@arg: roleId ")
    @PostMapping("/deleteRole")
    public JsonResult deleteRole(@RequestBody ModifyRoleRespVo modifyRoleRespVo){
        return ebcRoleService.DeleteRole(modifyRoleRespVo);
    }

}
